/**
 * @file    dlist.c
 * @author  Azolla (1228449928@qq.com)
 * @brief   doubly linked list
 * @version 0.1
 * @date    2025-04-15
 *
 * @copyright Copyright (c) 2025
 * */
 
#if 0

#define TAG                 "slist"
#define LOG_SET_LEVEL        LOG_LEVEL_DBG
#include "log_level.h"       /*!< Must be placed after LOG_SET_LEVEL >*/

#include "dlist.h"
// https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/unit/list/dlist.c
static sys_dlist_t dlist;

/* test iterator from a node */
struct data_node {
    sys_dnode_t node;
    int data;
};

static struct data_node test_node[11];

void dlist_test(void)
{
    sys_dnode_t *node = NULL;
    sys_dlist_init(&dlist);

    /* Appending node */
    for (int i = 0; i < 10; i++) {
        test_node[i].data = i + 1;
        sys_dlist_append(&dlist, &test_node[i].node);
    }

    if (sys_dlist_is_head(&dlist, &test_node[0].node)) {
        LOGI("dlist_is_head...");
    }
    if (sys_dlist_is_tail(&dlist, &test_node[9].node)) {
        LOGI("dlist_is_tail...");
    }

    /* Prepending node */
    test_node[10].data = 11;
    sys_dlist_prepend(&dlist, &test_node[10].node);
    if (sys_dlist_is_head(&dlist, &test_node[10].node)) {
        LOGI("dlist_is_head...");
    }

    /* Getting node */
    for (int i = 0; i < 11; i++) {
        node = sys_dlist_get(&dlist);
        if (node == NULL) break;
        LOGI("expected %d got %d", i, ((struct data_node *)node)->data);
    }
    LOGI("%s end...", __func__);
    return;
}
#endif

